<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">
    <base href="<%=basePath%>">
    <title>用户登录</title>
    <jsp:include page="bs/bs.jsp"></jsp:include>
    <style type="text/css">


        .form-signin {
            max-width: 330px;
            padding: 15px;
            margin: 0 auto;
        }
        .form-signin .form-signin-heading,
        .form-signin .checkbox {
            margin-bottom: 10px;
        }
        .form-signin .checkbox {
            font-weight: normal;
        }
        .form-signin .form-control {
            position: relative;
            height: auto;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            padding: 10px;
            font-size: 16px;
        }
        .form-signin .form-control:focus {
            z-index: 2;
        }
        .form-signin input[type="email"] {
            margin-bottom: -1px;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
        }
        .form-signin input[type="password"] {
            margin-bottom: 10px;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }

    </style>
</head>
<!-- NAVBAR
================================================== -->
<body>
<%--如果当前 用户已经登录 跳转到首页--%>
<c:if test="${!empty u }">
    <c:redirect url="index.jsp"></c:redirect>
</c:if>
<%--头部导航条--%>
<jsp:include page="common/top.jsp"></jsp:include>

<%
    //读cookie
    Cookie[] cookies = request.getCookies();
    for(int i=0;cookies!=null && i<cookies.length;i++){
        if(cookies[i].getName().equals("remember")){
            //从cookie取出   用户名密码  放在 域对象
            String value = cookies[i].getValue();
            String[] split = value.split("-");
            String uname = split[0];
            String upwd = split[1];

            request.setAttribute("uname",uname);
            request.setAttribute("upwd",upwd);
        }
    }

%>

<div class="container" style="height:500px;">
    <form class="form-signin" action="${pageContext.request.contextPath}/login" method="post">
        <h2 class="form-signin-heading">用户登录</h2>
        <label for="inputUsername" class="sr-only">用户名</label>
        <input type="text" name="uname" id="inputUsername" class="form-control" value="${uname}" placeholder="用户名" required autofocus>
        <label for="inputPassword" class="sr-only">密码</label>
        <input type="password" name="upwd" id="inputPassword" class="form-control" value="${upwd}"  placeholder="密码" required>
        <div class="checkbox">
            <label>
                记住我：
                <input type="radio" name="remember" value="${60*60}"> 一小时

            </label>
            <label >
                <input type="radio" name="remember" value="${60*60*24}"> 一天
            </label>
            <label >
                <input type="radio" name="remember" value="${60*60*24*7}"> 一周
            </label>

        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">登录</button>
        <br>
        ${login_info }
    </form>
</div>



<jsp:include page="common/footer.jsp"></jsp:include>


</body>
</html>

